package de.duester.genealogy.model.service;

import java.util.ArrayList;
import java.util.List;

import de.duester.genealogy.model.Date;
import de.duester.genealogy.model.Event;
import de.duester.genealogy.model.EventDate;
import de.greenrobot.dao.DaoException;

public class DateService {

	public static List<Event> getEvents(Date date) {
		List<Event> list = new ArrayList<Event>();
		try {
			for (EventDate ed : date.getEventDates())
				if (!list.contains(ed.getEvent()))
					list.add(ed.getEvent());
		} catch (DaoException e) {
		}
		return list;
	}

	public static List<Event> getEvents(Date date, String typeCode) {
		List<Event> list = new ArrayList<Event>();
		List<Event> events = getEvents(date);
		for (Event event : events)
			if (event.getTypeCode().equals(typeCode))
				list.add(event);
		return list;
	}
}
